import numpy as np
import tensorflow as tf

x = tf.Variable(tf.random_normal([3, 4], stddev=1))
#x = [tf.Variable(0) for i in range(10)]

y = tf.Variable(tf.random_normal([3, 4], stddev=1))


B = tf.placeholder(dtype=tf.int32, shape=[2])
C = tf.gather_nd(x, B)
D = tf.placeholder(dtype=tf.int32, shape=[4, 3, 2])
E = tf.gather_nd(x, D)

#y = [tf.Variable(x[1]) for i in range(10)]


def func(x):
  return x

init = tf.global_variables_initializer()

with tf.Session() as sess:
  sess.run(init)
  print("====================")
  print(sess.run(x))
  print("====================")
  print(sess.run(y))
  #op = tf.assign(x[0], 7777)
  #op = tf.assign(tf.where(x[0][0], tf.Variable(777), x));
  #op = tf.assign(x[0], 777);
  print("====================")
  aa = []
  for i in range(3):
    aa.append([])
    for j in range(4):
      _a = func(sess.run(C, feed_dict={B:[i,j]}))
      print(_a)
      aa[i].append(_a)
  print("====================")
  print(aa)  
  #op = tf.assign(y, tf.Variable(aa, dtype=tf.float32))
  op = tf.assign(y, aa)
  sess.run(op)
  print("====================")
  print(sess.run(y))

  #n = [[i for col in range(2)] for row in range(4)]
  n = []
  print("====================")
  print(n)
  for i in range(4):
   n.append([])
   for j in range(3):
     n[i].append([i, j])
  print("====================")
  print(n)
  #print(func(sess.run(E, feed_dict={D:n})))

  #sess.run(op)
  #print(sess.run(x))
  #print(sess.run(y))

